
import requests
# 添加员工
url = "http://ihrm-test.itheima.net/api/sys/user"
header = {"Content-Type": "application/json", "Authorization": "Bearer 27842bce-3bf1-4ec3-a522-7c37323476b0"}
json_data = { "username": "业务猪008", "mobile": "13676737843", "workNumber": "9527"}
resp = requests.post(url=url, headers=header, json=json_data)
print("添加员工：", resp.json())


# 查询员工
url_query = "http://ihrm-test.itheima.net/api/sys/user/1509452357891645440"

header_query = {"Content-Type": "application/json", "Authorization": "Bearer 27842bce-3bf1-4ec3-a522-7c37323476b0"}
resp_query = requests.get(url=url_query, headers=header_query)
print("查询员工：", resp_query.json())

# 修改员工
url_modify = "http://ihrm-test.itheima.net/api/sys/user/1509452357891645440"

header_modify = {"Content-Type": "application/json", "Authorization": "Bearer 27842bce-3bf1-4ec3-a522-7c37323476b0"}
modify_json={"username":"哈哈哈哈"}
resp_modify = requests.put(url=url_modify, headers=header_modify,json=modify_json)
print("修改员工：", resp_modify.json())


# 删除员工
url_delete = "http://ihrm-test.itheima.net/api/sys/user/1509452357891645440"
header_delete  = {"Content-Type": "application/json", "Authorization": "Bearer 27842bce-3bf1-4ec3-a522-7c37323476b0"}
resp_delete  = requests.delete(url=url_delete, headers=header_delete)
print("删除员工：", resp_delete.json())